package com.ict.web.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ict.common.annotation.Excel;
import com.ict.common.utils.bean.BeanUtils;
import com.ict.common.utils.uuid.IdUtils;
import com.ict.web.controller.file.domain.YzqFile;
import com.ict.web.domain.AnnualDeclaration;
import com.ict.web.domain.PreliminaryInformation;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.Date;
@Data
public class PreliminaryInformationAddDto {
    /** 项目id */
    @ApiModelProperty(value = "项目id")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @NotNull(message = "项目id不能为空")
    private Long proId;

    /** 初验时间 */
    @ApiModelProperty(value = "初验时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "初验时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date initialAcceptanceTime;

    /** 机构名称 */
    @ApiModelProperty(value = "机构名称")
    @Excel(name = "机构名称")
    private String organizationName;

    /** 初验通过凭证 */
    @ApiModelProperty(value = "初验通过凭证")
    @Excel(name = "初验通过凭证")
    private YzqFile certificate;

    /**
     * 将 PreliminaryInformationAddDto 转化为 PreliminaryInformation
     *
     * @param dto 接收dto
     * @return HotelInfo
     */
    public static PreliminaryInformation of(PreliminaryInformationAddDto dto){
        PreliminaryInformation bean = new PreliminaryInformation();
        BeanUtils.copyProperties(dto,bean);

        //设置ID
        bean.setFirstCheckId(IdUtils.snowId());
        //设置创建时间
        bean.setCreateTime(LocalDateTime.now());
        //设置创建时间
        bean.setUpdateTime(LocalDateTime.now());
        //设置物理删除标记
        bean.setDelFlag("0");

        return bean;
    }
}
